Edit This Code:
See Result »
<!DOCTYPE html> <html> <body> <p>Click the button to get the text of the third child node (index 2) of the select element.</p> <select id="mySelect" size="4"><option>Audi</option><option>BMW</option><option>Saab</option><option>Volvo</option></select><br><br> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var c = document.getElementById("mySelect").childNodes; document.getElementById("demo").innerHTML = c[2].text; } </script> </body> </html>
Result: